package com.ykdl.member.kid.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.ykdl.member.kid.R;
import com.ykdl.member.base.GlobalContext;
import com.ykdl.member.kid.beans.AdvertBean;
import com.ykdl.member.kid.image.ImageOptionsFactory;
import com.ykdl.member.kid.widget.AsyncImageView;
/**
 * 
 * 展示位 的适配器
 *
 * @see
 * @since 1.0
 */
public class ShowsiteAdatper extends BaseAdapter {
	private ArrayList<AdvertBean> list;
	private String TAG;
	private Context mContext;
	private BitmapUtils bitmapUtil ;
	public ShowsiteAdatper(Context mcontext, String tag) {
		TAG = tag;
		mContext = mcontext;
		bitmapUtil = new BitmapUtils(mContext);
	}

	public void setGalleryList(ArrayList<AdvertBean> list) {

		this.list = list;
		// layouttool= LayoutInflater.from(mcontext);
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 2;
	}

	@Override
	public int getCount() {
		if (list != null) {
			return list.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		GalleryHolder holder = null;
		if (convertView == null) {
			holder = new GalleryHolder();
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.iask_new_gallery_item, null);
			holder.gallery_bigimg = (AsyncImageView) convertView
					.findViewById(R.id.gallery_bigimg);
			convertView.setTag(holder);
		} else {
			holder = (GalleryHolder) convertView.getTag();
		}
		if (list.get(position).getFilemeta() != null) {
			String url = list.get(position).getFilemeta().getDownload_urls()
					.getOrigin().getUrl();
			bitmapUtil.display(holder.gallery_bigimg, url);
		}
		return convertView;
	}

}


class GalleryHolder {
	AsyncImageView gallery_bigimg;
}
